﻿
@model RTW.OA.Models.official_document
@{

    Layout = "~/Views/Shared/_LayoutBase.cshtml";
}

@section styles{

}
<div id="dMain">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox" style="margin-bottom: 0px;">
            <div class="ibox-title">
                <h4>@ViewBag.Title </h4>
            </div>
            <div class="ibox-content">
                @using (Html.BeginForm("Edit", "Send", FormMethod.Post, new { area = "Document", id = "form", name = "form" }))
                {
                    @Html.AntiForgeryToken()

                    <div class="from-content">
                        <dl>
                            <dt>公文标题</dt>
                            <dd>
                                @Html.EditorFor(m => m.SUBJECT, new { htmlAttributes = new { @class = "input normal form-control" } })
                            </dd>
                        </dl>
                        <dl>
                            <dt>正文</dt>
                            <dd>
                                @Html.TextAreaFor(m => m.BODY, new { @class = "editor" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>紧急程度</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownList("URGENT_LEVEL", ViewBag.URGENT_LEVEL_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>秘密等级</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownList("SECRET_LEVEL", ViewBag.SECRET_LEVEL_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>发文页数</dt>
                            <dd>
                                @Html.TextBoxFor(m => m.DOC_PAGE_COUNT, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>拟稿单位</dt>
                            <dd>
                                @Html.EditorFor(m => m.DRAFT_UNIT, new { htmlAttributes = new { @class = "input normal form-control" } })
                            </dd>
                        </dl>
                        <dl>
                            <dt>拟稿人</dt>
                            <dd>
                                @Html.EditorFor(m => m.DRAFT_AUTHOR, new { htmlAttributes = new { @class = "input normal form-control" } })
                            </dd>
                        </dl>
                        <dl>
                            <dt>主送单位</dt>
                            <dd>
                                @Html.TextArea("RECEIVE_UNITS_TEXT", new { @class = "input normal form-control", @readonly = "readonly" })
                                @Html.HiddenFor(m => m.RECEIVE_UNITS)
                            </dd>
                        </dl>
                        <dl>
                            <dt>接收人</dt>
                            <dd>
                                @Html.TextArea("RECEIVERS_TEXT", new { @class = "input normal form-control", @readonly = "readonly" })
                                @Html.HiddenFor(m => m.RECEIVERS)
                            </dd>
                        </dl>
                        <dl>
                            <dt>主送<br /><span style="font-size:10px;color:red;font-weight:normal;">用于套红头</span></dt>
                            <dd>
                                @Html.TextAreaFor(m => m.RED_HEAD_RECEIVE_UNITS, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>抄送<br /><span style="font-size:10px;color:red;font-weight:normal;">用于套红头</span></dt>
                            <dd>
                                @Html.TextAreaFor(m => m.RED_HEAD_CC, new { @class = "input normal form-control" })
                            </dd>
                        </dl>
                        <dl>
                            <dt>文件类别</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownList("DOC_CATEGORY", ViewBag.DOC_CATEGORY_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                            </dd>
                        </dl>
                        <dl>
                            <dt>使用模板</dt>
                            <dd>
                                <div class="rule-single-select">
                                    @Html.DropDownListFor(m => m.TEMPLATE, ViewBag.TEMPLATE_LIST as IEnumerable<SelectListItem>, new { @class = "form-control" })
                                </div>
                                <a target="_blank" href="/upload/201812/06/201812061028494007.docx">下载模板</a>
                            </dd>
                        </dl>
                        <dl>
                            <dt>上传文件</dt>
                            <dd>
                                @Html.TextBoxFor(m => m.ATTACHMENT, new { @class = "input normal upload-path" })
                                <div class="upload-box upload-img"></div>
                                @if (Model != null && !string.IsNullOrEmpty(Model.ATTACHMENT))
                                {
                                    <a target="_blank" href="javascript:POBrowser.openWindowModeless('/document/send/officeview?filePath=@Model.ATTACHMENT', 'width=1200px;height=800px;');">在线预览</a>
                                }
                            </dd>
                        </dl>
                        @Html.HiddenFor(m => m.DOC_ID)
                        @Html.HiddenFor(m => m.DEPT_LEADER)
                        @Html.HiddenFor(m => m.DEPT_LEADER_USER_NO)
                    </div>
                    <div class="from-footer">
                        <div class="btn-wrap" style="position: fixed;">
                            <a class="btn btn-sm btn-primary radius" onclick="approval(1)">
                                <i class="iconfont icon-save"></i>
                                批示通过
                            </a>
                            <a class="btn btn-sm btn-warning radius" data-toggle="modal" data-target="#approval-modal">
                                <i class="iconfont icon-fanhui"></i>
                                指示不通过
                            </a>
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
    <div class="modal fade" id="approval-modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h3 class="modal-title" id="myModalLabel">
                        批示不通过
                    </h3>
                </div>
                <div class="modal-body">
                    <textarea id="remark" rows="6" style="width:100%;" placeholder="请输入批示不通过的原因"></textarea>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">
                        关闭
                    </button>
                    <button type="button" class="btn btn-primary" onclick="approval(0);">
                        确定
                    </button>
                </div>
            </div>
        </div>
    </div>
</div>
@section scripts{
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/pageoffice/js/pageoffice.js")" id="po_js_main"></script>
    <script src="@Url.Content("~/Content/JS/common/WdatePicker/WdatePicker.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/jquery/Validform_v5.3.2_min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/artdialog/dialog-plus-min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/webuploader/webuploader.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.config.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/ueditor.all.min.js")"></script>
    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/editor/lang/zh-cn/zh-cn.js")"></script>

    <script type="text/javascript" charset="utf-8" src="@Url.Content("~/Content/JS/common/uploader.js")"></script>
    @*<script type="text/javascript" charset="utf-8" src="../js/uploader.js"></script>*@

    <script src="@Url.Content("~/Content/JS/common/from.js")"></script>

    <script src="@Url.Content("~/Content/js/common/signalR/jquery.signalR-2.4.0.min.js")"></script>
    <script src="@Url.Content("~/signalr/hubs")"></script>
    <script src="@Url.Content("~/Content/js/common/signalR/signalRContext.js")"></script>
    <script>
        $(function () {
            //初始化表单验证
            $("#form").initValidform();
            $(".upload-img").InitUploader({ filesize: "@RTW.OA.Servers.CommServers.LoadSysConfig().imgsize", sendurl: "@Url.Content("~/Ashx/Upload_ajax.ashx")", swf: "@Url.Content("~/Content/js/common/webuploader/uploader.swf")", filetypes: "@RTW.OA.Servers.CommServers.LoadSysConfig().fileextension" });
        });
        function savefrom() {
            $("#form").submit();
        }

        //初始化编辑器
        $(".editor").each(function (i) {
            var objId = $(this).attr("id");
            if (objId != "undefined") {
                var editor = UE.getEditor(objId, {
                    serverUrl: '../../../Ashx/Upload_ajax.ashx',
                    initialFrameWidth: '100%',
                    initialFrameHeight: 350
                });
            }
        });

        $(".editor-mini").each(function (i) {
            var objId = $(this).attr("id");
            if (objId != "undefined") {
                var editorMini = UE.getEditor(objId, {
                    serverUrl: '../../../Ashx/Upload_ajax.ashx',
                    initialFrameWidth: '100%',
                    initialFrameHeight: 250,
                    toolbars: [[
                        'fullscreen', 'source', '|', 'undo', 'redo', '|',
                        'bold', 'italic', 'underline', 'strikethrough', 'removeformat', 'pasteplain', '|', 'forecolor', 'insertorderedlist', 'insertunorderedlist', '|',
                        'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                        'link', 'unlink', 'anchor', '|',
                        'simpleupload', 'insertimage', 'scrawl', 'insertvideo'
                    ]]
                });
            }
        });

        function approval(status) {
            var docId = $("#DOC_ID").val();
            if (status == 0) {
                var remark = $("#remark").val();
                if (remark == "" || remark.length < 1) {
                    alert("请输入批示不通过原因");
                    return false;
                }
                $.post("/Document/Send/SetApproval", {
                    id: docId,
                    remark: remark,
                    status: 2
                    },
                    function (result) {
                        $("#approval-modal").modal("hide");
                        sendMessage("@Model.DRAFT_USER_NO", "official_document", "公文批示通知", "/document/send/index", null);
                        layer.msg('设置成功！', {
                            icon: 1,
                            time: 2000//2s后自动关闭
                        }, function () {
                            parent.subcloseTab('1303');
                        });
                });

            } else {
                layer.confirm('是否确认批示通过？', {
                    btn: ['确定', '取消'] //按钮
                }, function () {
                    $.post("/Document/Send/SetApproval", {
                        id: docId,
                        status: 3,
                        remark: null
                    }, function (result) {
                        $("#approval-modal").modal("hide");
                        sendMessage("@Model.DRAFT_USER_NO", "official_document", "公文批示通知", "/document/send/index", null);
                        layer.msg('设置成功！', {
                            icon: 1,
                            time: 2000//2s后自动关闭
                        }, function () {
                            parent.subcloseTab('1303');
                        });
                    });
                }, function () {

                });
            }
        }
    </script>

}